<?php
/*
 * Copyright notice
 * 
 * (c) 2009 MH-Dev.de, Martin Hesse <info@mh-dev.de>
 * 
 * This script is part of the MH-Dev.-Board project. The MH-Dev.-Board 
 * is free software; you can redistribute it and/or modify it under the 
 * terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, 
 * or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty 
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU 
 * General Public License along with this program; if not, 
 * see http://www.gnu.org/licenses/.
 */


/**
 * View_Helper GetNewestUser
 * 
 * @author	Martin Hesse <info@mh-dev.de>
 * @package	MH-Dev.-Board
 */
class MHDEV_View_Helper_GetNewestUser extends Zend_View_Helper_Abstract
{
	/*
	 * Get user sorted by registration date
	 * 
	 * @param null
	 * 
	 * @return string content
	 */
	public function GetNewestUser()
	{
		// lang
		$translate	= Zend_Registry::get('lang');
		
		// helper
		$url		= new Zend_View_Helper_Url();
		
		// db
		$user		= new User();
		
		// query
		$getUser	= $user->fetchAll(null, 'create_date DESC', 1);
		
		if($getUser->count() > 0)
		{
			$resUser	= $getUser->toArray();
			$user_url	= $url->url(array('controller' => 'profile', 'uid' => $resUser[0]['uid']), 'profile', true);
			$username	= '<a href="' . $user_url . '">' . $resUser[0]['username'] . '</a>';
			
			$values	= array('%user' => $username);
			return MHDEV_Sprintf($translate->_('latest_user'), $values);
		}
		else
		{
			return $translate->_('error_latest_user');
		}
	}
}